<?php
class Sosweb_Controller_Plugin_ApplicationInit extends Zend_Controller_Plugin_Abstract 
{
    public function routeStartup(Zend_Controller_Request_Abstract $request)
    {
        //use layout view pattern
        Zend_Layout::startMvc()->getView();

        $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
        //set BaseURL
   		$viewRenderer->view->baseUrl = $request->getBaseUrl();
   		//set additional View Helpers
   		$viewRenderer->view->addHelperPath('Sosweb/View/Helper', 'Sosweb_View_Helper');
   		        
        //set Doctype
        $viewDoctype = $viewRenderer->view->getHelper('Doctype');
        $viewDoctype->doctype('XHTML1_TRANSITIONAL');
        
        //set Title
        $viewHeadTitle = $viewRenderer->view->getHelper('HeadTitle');
        $viewHeadTitle->headTitle('.: Szkoła Jazdy Kopaczewski Bydgoszcz :. Najlepsza Szkoła w rankingu WORD : Nauka Jazdy Bydgoszcz : Kursy Prawa Jazdy Bydgoszcz'); 
		                      
        //set MetaLinks
        $viewHeadLinks = $viewRenderer->view->getHelper('HeadLink');
        $viewHeadLinks->appendStylesheet($request->getBaseUrl().'/public/styles/reset.css')
                      ->appendStylesheet($request->getBaseUrl().'/public/styles/layout.css')
                      ->appendStylesheet($request->getBaseUrl().'/public/scripts/fancybox/jquery.fancybox.css');
					  
        //set Meta keywords, Content Type and Character Set
        $viewHeadMeta = $viewRenderer->view->getHelper('HeadMeta');
        $viewHeadMeta->appendName('description', 'Szkoła Jazdy Kopaczewski Bydgoszcz, Najlepsza szkoła jazdy w rankingu WORD, profesjonalne szkolenie kierowców, kurs prawa jazdy, prawo jazdy Bydgoszcz, nauka jazdy Bydgoszcz.')
        			 ->appendName('verify-v1', 'KXG2B8p3Ekfnt/oeet9el+MZSoAK89NQlWxtl/XPSJ4=')
                     ->appendHttpEquiv('pragma', 'no-cache')
                     ->appendHttpEquiv('Cache-Control', 'no-cache')
                     ->appendHttpEquiv('Content-Type', 'text/html; charset=utf-8;')
                     ->appendHttpEquiv('Content-Language', 'pl-PL');

		$ganalyticsScript = 
			'var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); '.
			'document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E")); '.
			'try { '.
			'var pageTracker = _gat._getTracker("UA-7505167-3"); '.
			'pageTracker._trackPageview(); '.
			'} catch(err) {}';
             
        $viewInlineScript = $viewRenderer->view->getHelper('InlineScript');  
        $viewInlineScript->appendFile($request->getBaseUrl().'/public/scripts/jquery-1.3.2.min.js')
                         ->appendFile($request->getBaseUrl().'/public/scripts/jquery.corner.js')
                         ->appendFile($request->getBaseUrl().'/public/scripts/jquery.cycle.js')
                         ->appendFile($request->getBaseUrl().'/public/scripts/jquery.scrollTo-min.js')
                         ->appendFile($request->getBaseUrl().'/public/scripts/jquery.easing.js')
                         ->appendFile($request->getBaseUrl().'/public/scripts/jquery.easing.compatibility.js')
                         ->appendFile($request->getBaseUrl().'/public/scripts/pngFix/jquery.pngFix.pack.js')
                         ->appendFile($request->getBaseUrl().'/public/scripts/fancybox/jquery.fancybox.pack.js')
                         ->appendFile($request->getBaseUrl().'/public/scripts/szkolajazdy.js')
                         ->appendScript($ganalyticsScript);
    }
}